package com.wzh.controll;

import com.wzh.pojo.Po.Sys;
import com.wzh.pojo.Po.UserRecord;
import com.wzh.pojo.Resp.DataResp;
import com.wzh.pojo.result;
import com.wzh.service.SysService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/Sys")
public class SysController {
    @Autowired
	private SysService sysService;


    /**
	 * 获取上线用户数据
	 * @return com.wzh.pojo.Resp.DataResp
	 * @since 2023/6/8 22:15
	 * @author WZH
	 */


	@PostMapping("/readUserData")
	@ResponseBody
	public DataResp getData(@RequestBody UserRecord userRecord){
		DataResp<Object> resp= sysService.getData(userRecord);
		return resp;
	};



	//读取系统配置
	@PostMapping("/read")
	@ResponseBody
	public result read(){
		Sys res = sysService.readSys();
		String mes=res!=null?"操作成功":"操作失败";
		Integer code=res!=null?200:300;
		return new result(mes,code,res);
	};




	@PostMapping("/update")
	@ResponseBody
	public result update(@RequestBody Sys sys) {
		Integer res = sysService.update(sys);
		String mes=res>0?"操作成功":"操作失败";
		Integer code=res>0?200:300;
		return new result(mes,code);
	}

}
